$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'sys/transaciton/list',
        datatype: "json",
        colModel: [
            {label: '交易id', name: 'transactionId', width: 45, key: true,align:"center"},
            {label: 'SN', name: 'sn', width: 75,align:"center"},
            {label: '终端号', name: 'merchantCode', sortable: false, width: 75,align:"center"},
            {label: '交易时间', name: 'transactionDate', width: 85,align:"center"},
            {label: '类别', name: 'terminalName', width: 60,align:"center"},
            {label: '型号', name: 'model', width: 90,align:"center"},
            {label: '是否Vip', name: 'isVip',  width: 45,align:"center"},
            {label: '是否激活', name: 'isActivation',  width: 85,formatter:function (value,options,row) {
                    return value==1? "未激活":"已激活";
                },align:"center"},
            {label: '激活时间', name: 'activationDate',  width: 85,formatter:function (value,options,row) {
                    return value==null? "未激活":"已激活";
                },align:"center"},
            {label: '是否线上', name: 'isOnline',  width: 85,align:"center"}
        ],
        viewrecords: true,
        height: 385,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });

    vm.BindType();

});
var exmiane;

var vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            sn: null,
            merchantCode: null,
            terminalType: 0
        },
        showList: true,
        title: null,
        roleList: {},
        user: {
            status: 1,
            deptId: null,
            deptName: null,
            roleIdList: []
        },
        terminalTypes: [],

    },
    methods: {
        query: function () {
            vm.reload();
        },
        add: function () {
            vm.showList = false;
            vm.title = "新增";

        },

        update: function () {
            var userId = getSelectedRow();
            if (userId == null) {
                return;
            }

            vm.showList = false;
            vm.title = "修改";

        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'sn': vm.q.sn,'merchantCode':vm.q.merchantCode,'termianlType':vm.q.termianlType},
                page: page
            }).trigger("reloadGrid");
        },
        BindType:function () {
            $.get(baseURL+"sys/terminal/sysTerTypeList",r=>{
                vm.$set(vm.terminalTypes, 0, {
                    terminalType: 0,
                    terminalName: "请选择类型"
                });
                for (var i = 0; i < r.list.length; i++) {
                    vm.$set(vm.terminalTypes, (i + 1), r.list[i]);
                }


            })
        }
       
    }
});